package com.xy.mainp.novel.fragment.home.widget;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.xy.debug.LogUtils;
import com.xy.img.GlideUtil;
import com.xy.mainp.HotBookItemBinding;
import com.xy.mainp.R;
import com.xy.mainp.config.NetAPI;
import com.xy.mainp.model.biqu.home.BiquHomeHotEntity;

/**
 * Created by John on 2016/12/5.
 */

public class HotBookItemView extends FrameLayout {


    private HotBookItemBinding binding;
    private BiquHomeHotEntity hotEntity;

    public HotBookItemView(Context context) {
        this(context,null);
    }

    public HotBookItemView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public HotBookItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        binding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.view_hot_book_item,this,true);
        setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                LogUtils.i(NetAPI.BIQU_BASE_URL+hotEntity);
            }
        });
    }

    public void setData(BiquHomeHotEntity hotEntity){
        this.hotEntity = hotEntity;
        binding.setHotEntity(hotEntity);
        GlideUtil.loadImage(NetAPI.BIQU_BASE_URL+hotEntity.getBookImgUrl(),binding.imgBook);
    }
}
